#6 Introduction to Python in VS Code
Faculty of Humanities and Social Sciences
University of Lucerne
27 April 2024
enter the shiny world of Python 😎
get familiar with Visual Studio Code
. . .
Programming can be absolutely captivating! ✌️
| Name | What for? | Type | Examples |
|---|---|---|---|
| String | Text | str | "Hi!" |
| Integer, Float | Numbers | int, float | 20, 4.5 |
| Boolean | Truth values | bool | True, False |
| ⋮ | ⋮ | ⋮ | ⋮ |
| List | List of items (ordered, mutable) | list | ["Good", "Afternoon", "Everybody"] |
| Tuple | List of items (ordered, immutable) | tuple | (1, 2) |
| Dictionary | Relations of items (unordered, mutable) | dict | {"a":1, "b": 2, "c": 3} |
= vs. == contradicts the intuitiontab for autocompletiongit pull in your command-line.WSL: Ubuntu (green badge lower-left corner, see image on the slide after the next). If not, click on the badge and select New WSL Window.Create a new file with the following content, save it as hello_world.py in the KED2024 folder. Then, execute it by a right click on the code and select Run current file in interactive window.
Does the output looks like the screenshot on the next slide? If the execution doesn’t work as expected, ask me or your neighbour. There might be a technical issue.
The Output “Hello World!” on the right side should look like in the screenshot
do something with each element of a collection
condition action on variable content
function_name(arg1, ..., argn)print(), len() and sorted()CTRL+EnterKED2024/materials/code/python_basics.ipynbis a from the variable sentence using the right index.Write a Python script that
Go to the next slide. Start with some of the great interactive exercises out there in the web.
Comments